home *** CD-ROM | disk | FTP | other *** search
/ PCMania 48 / PCMania CD48_1.iso / pcmania / virus48 / antijunk.c next >
C/C++ Source or Header  |  1996-07-29  |  20KB  |  653 lines

  1. /*----------------------------------------------*/
  2. /* ANTIJUNK (c) 1996 Por Javier Guerrero Díaz 
  3. /* Rastrea el sistema en busca del virus JUNKIE.
  4. /*
  5. /* La sintaxis es: ANTIJUNK <unidad:\directorio>.
  6. /* El programa buscará el virus en el boot sector de 
  7. /* la unidad especificada y en los archivos de la misma.
  8. /* Programado con Borland C++ 5.0.
  9. /*----------------------------------------------*/
  10. /*      Javier Guerrero Díaz     */
  11. /*              ALGECIRAS        */
  12. /*          (CADIZ)              */
  13. /*-------------------------------*/
  14.  
  15. #include <stdio.h>
  16. #include <dos.h>
  17. #include <dir.h>
  18. #include <conio.h>
  19. #include <bios.h>
  20. #include <stdlib.h>
  21. #include <direct.h>
  22. #include <string.h>
  23. #include <io.h>
  24.  
  25. void fin(void);
  26. void mal(void);
  27. void intro(void);
  28. void buscafichero(void);
  29. void panta(void);
  30. void obtieneinfo(void);
  31. void buscamem(void);
  32. void busca(void);
  33. void mensaje(char *mensa);
  34. void errorhand(int);
  35. void leeboot(void);
  36. void buscaenboot(void);
  37. void mataboot(void);
  38. void analiza(void);
  39. void encontrado(void);
  40. void matavir(void);
  41. void atributo(char);
  42.  
  43. union REGS registros;
  44. char tecla,diractual[50],dirdestino[50];
  45. int temp,infec=0,analiz=0,drive,pulsa,segmento,despl,despla,oldrive;
  46. unsigned int corta;
  47. unsigned long memlibre=0;
  48. FILE *fichero;
  49. struct ffblk arch;
  50. struct date fecha;
  51. struct dostime_t hora;
  52.  
  53. char far *memo;
  54. int far *direcc,sector,cabeza,*virus;
  55. char unidad,cambio,buffer[512],letra;
  56. char cadena[]={ 0x2e,0x80,0x3E,0x60,0x03,0x01,0x74,0x3C,0x1E,0x06,0x50,0x56,
  57.         0x57,0xBE,0x84,0x00,0x33,0xC0,0x8E,0xD8,0xA1,0x82 };
  58. char bytes[1024];
  59. unsigned char jmp;
  60.  
  61. void main(argc,argv)
  62. int argc;
  63. char *argv[];
  64. {
  65. if (*argv[1]==NULL || *argv[1]=='?') 
  66.         { printf("\nANTIJUNKIE (c)1996 Por Javier Guerrero Díaz\n");
  67.               printf("Sintaxis: ANTIJUNK <unidad:\directorio>\n"); exit(-1);}
  68.  
  69. getcwd(diractual,50);
  70. oldrive=getdisk();
  71. _setcursortype(_NOCURSOR);
  72.  
  73. if (*argv[1]=='a' || *argv[1]=='A') { drive=1; unidad=0; }
  74. else if (*argv[1]=='b' || *argv[1]=='B') { drive=2; unidad=1; }
  75. if (*argv[1]=='c' || *argv[1]=='C') { drive=3; unidad=0x80; }
  76. else if (*argv[1]=='d' || *argv[1]=='D') { drive=4; unidad=0x81; }
  77. if (*argv[1]=='e' || *argv[1]=='E') { drive=5; unidad=0x82; }
  78. letra=*argv[1];
  79.  
  80. if (_chdrive(drive)==-1) { printf("\nError. No puedo acceder a la unidad ");
  81.             printf("%s.\n",argv[1]); mal(); }
  82.  
  83. if (chdir(argv[1])==-1) { printf("\nError. No puedo acceder al directorio ");
  84.             printf("%s.\n",argv[1]); mal(); }
  85.  
  86. getcwd(dirdestino,50);
  87. intro();
  88. panta();
  89. buscamem();
  90. buscafichero();
  91. fin();
  92. }
  93.  
  94. void matavir(void)
  95. {
  96. int res,handle;
  97. int far *word1;
  98. int far *word2;
  99. char prot='N';
  100. char far *atr;
  101.  
  102. atr=(char far *)&arch.ff_attrib; 
  103. if ((*atr & 1)) { *atr=*atr ^ 1; prot='Y'; }
  104. word1=(int far*)MK_FP(FP_SEG(bytes),FP_OFF(bytes)+25);
  105. word2=(int far*)MK_FP(FP_SEG(bytes),FP_OFF(bytes)+30);
  106. asm {
  107.     push    ax
  108.     push    bx
  109.     push    cx
  110.     push    dx
  111.     push    si
  112.     push    di
  113.     push    ds
  114.     push    es
  115.     pushf
  116.  
  117.     mov     ax,seg bytes
  118.     mov     ds,ax
  119.     mov     es,ax
  120.     mov     cx,01F4h
  121.     mov     si,offset bytes
  122.     add     si,0Dh
  123.     mov     di,offset bytes
  124.     add     di,07h
  125.     mov     bx,es:[di]
  126. bucle:
  127.     xor     word ptr es:[si],bx
  128.     inc     si
  129.     inc     si
  130.     loop    bucle   
  131.  
  132.     popf
  133.     pop     es
  134.     pop     ds
  135.     pop     di
  136.     pop     si
  137.     pop     dx
  138.     pop     cx
  139.     pop     bx
  140.     pop     ax
  141. }
  142. rewind(fichero); res=putw(*word1,fichero); 
  143. res=putw(*word2,fichero); rewind(fichero);
  144. res=fseek(fichero,corta,SEEK_SET);
  145.     if (res!=0) {
  146.              mensaje("Error gestionando fichero!."); mal();
  147.             }
  148. handle=fileno(fichero); res=chsize(handle,corta);
  149. if (res!=0) { 
  150.          mensaje("Error al modificar el tamaño del archivo."); mal();
  151.         }
  152. if (prot=='Y') *atr=*atr | 1;
  153. mensaje("OK!. Virus eliminado del fichero.");
  154. }
  155.  
  156. void analiza(void)
  157. {
  158. unsigned char dummy;
  159. int res,resto;
  160. unsigned int salto;
  161. int far *marca;
  162.  
  163. marca=(int far*)MK_FP(FP_SEG(bytes),FP_OFF(bytes)); marca++; rewind(fichero);
  164. resto=arch.ff_fsize%16; if (resto!=3) goto sale;
  165. dummy=fgetc(fichero); if (dummy!=0xE9) goto sale;
  166. salto=getw(fichero); corta=salto+3;
  167. salto+=3; rewind(fichero);
  168. res=fseek(fichero,salto,SEEK_SET);
  169.     if (res!=0) { 
  170.              mensaje("Error gestionando fichero!."); mal();
  171.             }
  172. salto=getw(fichero);
  173. res=fread(bytes,1,1024,fichero);
  174.     if (res!=1024) { 
  175.              mensaje("Error leyendo archivo!."); mal();
  176.             }
  177. if (*marca!=0x01F4) goto sale;
  178. marca++; if (*marca!=0x8126) goto sale;
  179. infec++; encontrado();
  180. textattr(LIGHTGRAY|BLACK<<4); clrscr(); panta(); obtieneinfo();
  181. sale:
  182. }
  183.  
  184. void encontrado(void)
  185. {
  186. window(22,8,57,20);
  187. textattr(WHITE|RED<<4);
  188. cprintf("╔═══════════╦══════════╦═══════════╗");
  189. cprintf("║           ║ ATENCION ║           ║");
  190. cprintf("║           ╚══════════╝           ║");
  191. cprintf("║                                  ║");
  192. cprintf("║                                  ║");
  193. cprintf("║                                  ║");
  194. cprintf("║                                  ║");
  195. cprintf("║                                  ║");
  196. cprintf("║ PULSE LA TECLA 'SUPR' PARA MATAR ║");
  197. cprintf("║  EL VIRUS O CUALQUIER OTRA PARA  ║");
  198. cprintf("║      IGNORAR ESTE FICHERO.       ║");
  199. cprintf("╚══════════════════════════════════╝");
  200. gotoxy(3,5); cprintf("SE DETECTO LA MARCA DE INFECCION");
  201. gotoxy(3,6); cprintf("   PROPIA DEL VIRUS 'JUNKIE',");
  202. gotoxy(3,7); cprintf("    EN ARCHIVO:");
  203.  
  204. textattr(YELLOW|RED<<4); gotoxy(19,7); cprintf("%-12s",arch.ff_name);
  205. textattr(WHITE|BLUE<<4); window(1,1,80,25);
  206. mensaje("Atención: Fichero infectado por el virus !."); 
  207. tecla:    pulsa=bioskey(0);
  208.         switch (pulsa)
  209.         {
  210.             case 0x5300:    matavir();
  211.                     break;
  212.             default:        break;
  213.         }
  214. }
  215.  
  216. void mataboot(void)
  217. {
  218. unsigned char media;
  219.  
  220. direcc=(int far*)MK_FP(segmento,despl);
  221. memo=(char far*)MK_FP(segmento,despl); memo+=0x15; media=*memo; 
  222. if (media==0xF9) 
  223. { registros.h.cl=8; registros.h.ch=0x4F; 
  224.   registros.h.dh=1; registros.h.dl=unidad; }
  225. else if (media==0xF0)
  226. { memo=(char far*)MK_FP(0x40,0x90); if (*memo==0x97) registros.h.cl=8;
  227. else registros.h.cl=0x11; 
  228. registros.h.ch=0x4F; registros.h.dh=1; registros.h.dl=unidad; }
  229. else if (unidad!=0 || unidad!=1)
  230. { registros.x.cx=4; registros.h.dh=0; registros.h.dl=unidad; }
  231. virus=malloc(1024); 
  232. if (virus==NULL) { 
  233. mensaje("Error: No se pudo reservar memoria para lectura.");
  234. mal(); }
  235. _ES=_DS; registros.x.ax=0x0202; registros.x.bx=virus; 
  236. int86(0x13,®istros,®istros);
  237. if (registros.x.cflag!=0) {
  238. mensaje("Error: No se pudo leer cuerpo del virus."); free(virus); mal(); }
  239.  
  240. asm {
  241.     push    ax
  242.     push    bx
  243.     push    cx
  244.     push    dx
  245.     push    si
  246.     push    di
  247.     push    ds
  248.     push    es
  249.     pushf
  250.  
  251.     mov     ax,seg virus
  252.     mov     ds,ax
  253.     mov     es,ax
  254.     mov     cx,01F4h
  255.     mov     si,virus
  256.     add     si,0Fh
  257.     mov     di,virus
  258.     add     di,09h
  259.     mov     bx,es:[di]
  260. bucle:
  261.     xor     word ptr es:[si],bx
  262.     inc     si
  263.     inc     si
  264.     loop    bucle   
  265.  
  266.     mov     ax,seg virus
  267.     mov     ds,ax
  268.     mov     si,virus
  269.     add     si,0378h
  270.     mov     ax,seg direcc
  271.     mov     es,ax
  272.     mov     di,word ptr direcc
  273.     movsw
  274.     mov     di,word ptr direcc
  275.     add     di,60h
  276.     cld
  277.     mov     cx,10h
  278.     rep     movsw           
  279.     
  280.     popf
  281.     pop     es
  282.     pop     ds
  283.     pop     di
  284.     pop     si
  285.     pop     dx
  286.     pop     cx
  287.     pop     bx
  288.     pop     ax
  289. }
  290. registros.x.ax=0x0301; registros.x.bx=despl; registros.x.cx=0x0001;
  291. registros.h.dh=0; registros.h.dl=unidad; _ES=_DS;
  292. int86(0x13,®istros,®istros);
  293. if (registros.x.cflag!=0) {
  294. mensaje("Error: No se pudo corregir boot sector."); free(virus); mal(); }
  295. free(virus); textattr(LIGHTGRAY|BLACK<<4); clrscr(); panta(); obtieneinfo();
  296. }
  297.  
  298. void buscaenboot(void)
  299. {
  300. char flag='N';
  301.  
  302. direcc=(int far*)MK_FP(segmento,despl);
  303. if (*direcc!=0x5EEB) flag=='N';
  304. else { direcc+=0x30; if (*direcc==0xFF33) flag='Y'; }
  305. if (flag=='Y') {
  306.      window(17,7,63,15); textattr(WHITE|RED<<4); putch(7);
  307.      cprintf("╔═════════════════════════════════════════════╗");
  308.      cprintf("║ Atención: Encontrada la rutina de infección ║");
  309.      cprintf("║  propia del virus JUNKIE en el boot sector  ║");
  310.      cprintf("║               de la unidad %c: .             ║",letra);
  311.      cprintf("║    Esta unidad se encuentra infectada por   ║");
  312.      cprintf("║    el virus. Pulse 'SUPR' para eliminarlo   ║");
  313.      cprintf("║    y comprobar los archivos de la unidad.   ║");
  314.      cprintf("╚═════════════════════════════════════════════╝");
  315.      mensaje("¡ Sector de arranque infectado !"); }
  316.  
  317. else  {  window(17,7,63,15); textattr(WHITE|CYAN<<4);
  318.      cprintf("╔═════════════════════════════════════════════╗");
  319.      cprintf("║  OK! El sector de arranque de la unidad %c:  ║",letra);
  320.      cprintf("║   no se encuentra infectado por el virus    ║");
  321.      cprintf("║     JUNKIE.El siguiente paso consistirá     ║");  
  322.      cprintf("║   en comprobar los archivos del directorio  ║");
  323.      cprintf("║ especificado para determinar si existe sín- ║");
  324.      cprintf("║       toma de infección en los mismos.      ║");
  325.      cprintf("╚═════════════════════════════════════════════╝");
  326.      window(1,1,80,25); textattr(WHITE|BLUE<<4); gotoxy(24,23);
  327.      cprintf("                                                  ");
  328.      gotoxy(24,23); cprintf("OK. Boot sector limpio.");
  329.      sleep(4); gotoxy(24,23);
  330.      cprintf("                                                  ");                 
  331.      textattr(LIGHTGRAY|BLACK<<4); clrscr(); panta(); goto salida;
  332.     }
  333. tecl:    pulsa=bioskey(0);
  334.         switch (pulsa)
  335.         {
  336.             case 283:       fin();
  337.                     break;
  338.             case 0x5300:    mataboot();
  339.                     goto salida;
  340.             default:        goto tecl;
  341.         }
  342.  
  343. salida:
  344. }
  345.  
  346. void buscamem(void)
  347. {
  348. window(18,7,62,11);
  349. textattr(WHITE|BLUE<<4);
  350. cprintf("╔═══════════════════════════════════════════╗");
  351. cprintf("║     Buscando virus JUNKIE en memoria.     ║");
  352. cprintf("║          Analizando la RAM .....          ║");
  353. cprintf("╚═══════════════════════════════════════════╝");
  354. sleep(1);
  355. busca();
  356. }
  357.  
  358. void busca(void)
  359. {
  360. char far *cop;
  361. char dummy;
  362.  
  363. direcc=(int far *)MK_FP(0x0000,0x0413);
  364. if (*direcc==0x27D) 
  365.     { 
  366.      window(17,7,63,15); textattr(YELLOW|RED<<4); putch(7);
  367.      cprintf("╔═════════════════════════════════════════════╗");
  368.      cprintf("║   Atención: La cantidad de memoria conven-  ║");
  369.      cprintf("║ cional en el sistema es inferior a 640 Kb;  ║");
  370.      cprintf("║  como otros muchos virus, el JUNKIE produ-  ║");
  371.      cprintf("║  ce este efecto. Se realizará un analisis   ║");
  372.      cprintf("║ de la memoria para determinar la existencia ║");
  373.      cprintf("║       en la misma del virus JUNKIE.         ║");
  374.      cprintf("╚═════════════════════════════════════════════╝");
  375.      mensaje("Encontrado síntoma de infección vírica."); sleep(5);       
  376.      textattr(LIGHTGRAY|BLACK<<4); clrscr(); panta();
  377.      }
  378. else goto noresid; 
  379. segmento=*direcc*64; 
  380. memo=(char far *)MK_FP(segmento,0x1EA); 
  381. cop=(char far *)MK_FP(segmento,586);
  382. for (temp=0;temp<sizeof cadena;temp++)
  383.     {
  384.      if (*memo!=cadena[temp]) goto noresid;
  385.      else memo++;
  386.     }
  387. window(14,7,66,21); textattr(YELLOW|RED<<4); 
  388. putch(7); 
  389. cprintf("╔═══════════════════════════════════════════════════╗");
  390. cprintf("║       Atención: Virus JUNKIE detectado en la      ║");
  391. cprintf("║          dirección de memoria : %X:0000         ║",segmento);
  392. cprintf("╟───────────────────────────────────────────────────╢");
  393. cprintf("║                                                   ║");
  394. cprintf("║                                                   ║");
  395. cprintf("║                                                   ║");
  396. cprintf("║                                                   ║");
  397. cprintf("║                                                   ║");
  398. cprintf("║                                                   ║");
  399. cprintf("║                                                   ║");
  400. cprintf("║                                                   ║");
  401. cprintf("║                                                   ║");
  402. cprintf("╚═══════════════════════════════════════════════════╝");
  403. window(15,11,65,20); textattr(WHITE|RED<<4);
  404. for (temp=0;temp<459;temp++) 
  405. { dummy=*cop; if (dummy<32) dummy='.'; cprintf("%c",dummy); cop++; }                    
  406. mensaje("¡ Virus encontrado en memoria !"); textattr(LIGHTGRAY|BLACK<<4);
  407. sleep(5); clrscr(); panta();
  408. window(17,7,63,15); textattr(WHITE|GREEN<<4); 
  409. cprintf("╔═════════════════════════════════════════════╗");
  410. cprintf("║ Atencion: El virus se encuentra en memoria. ║");
  411. cprintf("║ Para el correcto funcionamiento de esta va- ║");
  412. cprintf("║ cuna es muy importante que el virus no esté ║");
  413. cprintf("║ residente en la memoria; se recomienda ini- ║");
  414. cprintf("║ciar el sistema con un disquete de DOS limpio║");
  415. cprintf("║ y protegido, y ejecutar de nuevo la vacuna. ║");
  416. cprintf("╚═════════════════════════════════════════════╝");
  417. window(23,13,62,13); textattr(YELLOW|BLUE<<4); exit(0);
  418. noresid:
  419. window(18,7,62,11);
  420. cprintf("╔═══════════════════════════════════════════╗");
  421. cprintf("║   OK !. No se encontró el virus en RAM.   ║");
  422. cprintf("║     Analizando boot de unidad %c: ....     ║",letra);
  423. cprintf("╚═══════════════════════════════════════════╝");
  424. leeboot(); buscaenboot();
  425. }
  426.  
  427. void obtieneinfo(void)
  428. {
  429. getdate(&fecha);
  430. _dos_gettime(&hora);
  431. registros.h.ah=0x48; registros.x.bx=0xFFFF;
  432. int86(0x21,®istros,®istros);
  433. memlibre=registros.x.bx; memlibre*=16;
  434. gotoxy(14,11); cprintf("%02d/%02d/%d",fecha.da_day,fecha.da_mon,fecha.da_year);
  435. gotoxy(34,11); cprintf("%02d:%02d:%02d",hora.hour,hora.minute,hora.second);
  436. gotoxy(62,11); cprintf("%ld",memlibre); gotoxy(32,13); cprintf("%s",dirdestino);
  437. }
  438.  
  439. void buscafichero(void)
  440. {
  441. char far *atr,prot='N';
  442.  
  443. temp=findfirst("*.*",&arch,0);
  444.     while (!temp)
  445.         { atr=(char far *)&arch.ff_attrib;
  446.           if ((*atr & 1)) { prot='Y'; atributo((*atr ^ 1)); }
  447.     obtieneinfo();
  448.     fichero=fopen(arch.ff_name,"r+b");
  449.         if (fichero==NULL) 
  450.         { gotoxy(24,23);
  451.           cprintf("                                                  ");
  452.           gotoxy(24,23); cprintf("Error abriendo fichero!"); putch(7);
  453.           sleep(1); gotoxy(24,23);
  454.           cprintf("                                                  ");                        
  455.         }
  456.         analiz++;
  457.         gotoxy(28,15);
  458.         cprintf("%-12s",arch.ff_name);
  459.         gotoxy(62,15);
  460.         cprintf("%-8ld",arch.ff_fsize);
  461.         gotoxy(33,17);
  462.         cprintf("%-3d",analiz); 
  463.         gotoxy(64,17);
  464.         cprintf("%-3d",infec);
  465.         analiza();
  466.         fclose(fichero);
  467.         if (prot=='Y') { atr=(char far *)&arch.ff_attrib;
  468.                  atributo((*atr | 1)); prot='N'; }
  469.         temp=findnext(&arch);
  470.         }
  471.  
  472. setdisk(oldrive);
  473. chdir(diractual);       
  474. }
  475.  
  476. void leeboot(void)
  477. {
  478. int resultado2;
  479. short resultado1;
  480.  
  481. segmento=FP_SEG(buffer); despl=FP_OFF(buffer); 
  482. direcc=(char far *)MK_FP(segmento,despl);
  483.  
  484. window(1,1,80,25); textattr(WHITE|BLUE<<4); gotoxy(24,23);
  485. cprintf("                                                  ");
  486. gotoxy(24,23); cprintf("Leyendo boot..."); sleep(1);
  487. gotoxy(24,23);
  488. cprintf("                                                  ");                 
  489.  
  490. asm     push    es
  491. asm     push    ds
  492. asm     mov     ah,0
  493. asm     mov     dl,byte ptr unidad
  494. asm     int     13h
  495. resultado1=_AH;
  496.     if (resultado1 !=0) errorhand(resultado1);
  497.  
  498. asm     mov     ah,15h
  499. asm     mov     dl,byte ptr unidad
  500. asm     int     13h
  501. asm     mov     byte ptr cambio,ah
  502.  
  503. asm     mov     ah,2
  504. asm     mov     dl,byte ptr unidad
  505. asm     mov     dh,0
  506. asm     mov     ch,0
  507. asm     mov     cl,1
  508. asm     mov     al,1
  509. asm     mov     es,segmento
  510. asm     mov     bx,despl
  511. asm     int     13h
  512. asm     mov     resultado2,ax
  513.     if (unidad==0 && resultado2 !=0x0001) 
  514.         errorhand(resultado2);
  515.     else if (unidad==1 && resultado2 !=0x0001)
  516.         errorhand(resultado2);
  517.     else if (unidad==0x80 && resultado2!=0) 
  518.         errorhand(resultado2);
  519.     else if (unidad==0x81 && resultado2!=0)
  520.         errorhand(resultado2);
  521. asm     
  522. {
  523.     mov     cx,0200h
  524.     mov     ax,segmento
  525.     mov     ds,ax
  526.     mov     si,despl
  527.     mov     ax,seg bytes
  528.     mov     es,ax
  529.     mov     di,offset bytes
  530.     rep     movsb   
  531.     pop     ds
  532.     pop     es
  533. }
  534. }
  535.  
  536. void intro(void)
  537. {
  538. clrscr(); gotoxy(20,9); textattr(YELLOW|BLUE<<4);
  539. cprintf("╔═════════════════════════════════════╗\n"); gotoxy(20,10);
  540. cprintf("║              ANTIJUNKIE             ║\n"); gotoxy(20,11);
  541. cprintf("║ (c) 1996  Por Javier Guerrero Diaz. ║\n"); gotoxy(20,12);
  542. cprintf("║  Rastrea los archivos de la unidad  ║\n"); gotoxy(20,13);
  543. cprintf("║  especificada como parámetro a la   ║\n"); gotoxy(20,14);
  544. cprintf("║     busqueda del virus JUNKIE.      ║\n"); gotoxy(20,15);
  545. cprintf("╚═════════════════════════════════════╝\n");
  546. textattr(LIGHTGRAY|BLACK<<4);tecla=getch();
  547. clrscr();
  548. }
  549.  
  550. void panta(void)
  551. {
  552. window(20,2,60,7);
  553. gotoxy(1,1);
  554. textattr(YELLOW|BLUE<<4);
  555. cprintf("╔═══════════════════════════════════════╗");
  556. cprintf("║  DETECTOR/VACUNA PARA EL VIRUS JUNKIE ║");
  557. cprintf("║     (C) Por Javier Guerrero Diaz      ║");
  558. cprintf("╚═══════════════════════════════════════╝");
  559. window(5,8,75,20);
  560. cprintf("╔═════════════════════════════════════════════════════════════════════╗");
  561. cprintf("║                         ANALISIS DE ARCHIVOS                        ║");
  562. cprintf("║                                                                     ║");
  563. cprintf("║ Fecha:               Hora:              Memoria Libre:        bytes ║");
  564. cprintf("║                                                                     ║");
  565. cprintf("║  Directorio de Búsqueda:                                            ║");
  566. cprintf("║                                                                     ║");
  567. cprintf("║  Nombre de Archivo :                 Longitud Archivo:              ║");
  568. cprintf("║                                                                     ║");
  569. cprintf("║      Archivos Analizados:           Archivos Infectados:            ║");
  570. cprintf("║                                                                     ║");
  571. cprintf("╚═════════════════════════════════════════════════════════════════════╝");
  572. window(1,22,80,25);
  573. cprintf("╔══════════════════════════════════════════════════════════════════════════════╗");
  574. cprintf("║ RESULTADO OPERACION:                                                         ║");
  575. cprintf("╚══════════════════════════════════════════════════════════════════════════════╝");
  576. textattr(WHITE|BLUE<<4); window(1,1,80,25);
  577. }
  578.  
  579. void errorhand(numerror)
  580. int numerror;
  581. {
  582.     switch(numerror)
  583.     {
  584.     case 0x0100:    mensaje("Error: Función no permitida.");
  585.             break;
  586.     case 0x0200:    mensaje("Error: Marca de direcciones no encontrada.");
  587.             break;
  588.     case 0x0300:    mensaje("Error: Disquete protegido contra escritura.");
  589.             break;
  590.     case 0x0400:    mensaje("Error: Sector no encontrado.");
  591.             break;
  592.     case 0x0600:
  593.             if (cambio!=2) 
  594.             { mensaje("Error: Disco retirado, pulsa tecla para repetir lectura.");
  595.                getch(); }
  596.             leeboot(); buscaenboot();
  597.             break;
  598.     case 0x0800:    mensaje("Error: Desbordamiento de DMA.");
  599.             break;
  600.     case 0x0900:    cprintf("Error: Superado el límite de 64k de segmento.");
  601.             break;
  602.     case 0x0c00:    mensaje("Error: Tipo de entorno no hallado.");
  603.             break;
  604.     case 0x1000:    mensaje("Error: Fallo de lectura.");
  605.             break;
  606.     case 0x2000:    mensaje("Error: Fallo de controladora de disco.");
  607.             break;
  608.     case 0x4000:    mensaje("Error: Pista no encontrada.");
  609.             break;
  610.     case 0x8000:    mensaje("Error: Time Out; unidad no responde.");
  611.             break;
  612.     default:        mensaje("Error: Fallo general.");
  613.             break;
  614.     }
  615. mal();
  616. }
  617.  
  618. void mensaje(mensa)
  619. char mensa[50];
  620. {
  621. window(1,1,80,25); textattr(WHITE|BLUE<<4); gotoxy(24,23);
  622. cprintf("                                                  ");
  623. gotoxy(24,23); cprintf("%s",mensa); putch(7);
  624. sleep(1); gotoxy(24,23);
  625. cprintf("                                                  ");                 
  626. }
  627.  
  628. void fin(void)
  629. {
  630. _setcursortype(_NORMALCURSOR); textattr(LIGHTGRAY|BLACK<<4);
  631. exit(0);
  632. }
  633.  
  634. void mal(void)
  635. {
  636. setdisk(oldrive);
  637. _setcursortype(_NORMALCURSOR); textattr(LIGHTGRAY|BLACK<<4);
  638. printf("\nPrograma finalizado anormalmente.\n");
  639. exit(-1);
  640. }
  641.  
  642. void atributo(attrib)
  643. char attrib;
  644. {
  645. int nombre;
  646.  
  647. registros.x.ax=0x4301; registros.x.cx=attrib;
  648. nombre=FP_OFF(&arch.ff_name); registros.x.dx=nombre;
  649. int86(0x21,®istros,®istros);
  650. if (registros.x.cflag!=0) {
  651. mensaje("Error: No se pudo cambiar atributo de fichero."); mal(); }
  652. }
  653.